package com.hzhr.iot.toll.dao;

import com.hzhr.iot.toll.dao.mapper.custom.GasUserEntityCustomMapper;
import com.hzhr.iot.toll.dao.mapper.generator.GasUserEntityMapper;
import com.hzhr.iot.toll.entity.GasUserEntity;
import com.hzhr.iot.toll.entity.ext.GasUserEntityExt;
import com.hzhr.iot.toll.queryModel.custom.GasUserCustomQueryModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class GasUserDao {
    @Autowired
    GasUserEntityMapper gasUserEntityMapper;
    @Autowired
    GasUserEntityCustomMapper gasUserEntityCustomMapper;

    public int insert(GasUserEntity record) {
        if (record == null) return 0;
        int changeCount = gasUserEntityMapper.insert(record);
        return changeCount;
    }

    public int delete(GasUserCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = gasUserEntityCustomMapper.delete(queryModel);
        return changeCount;
    }

    public int update(GasUserEntity record) {
        if (record == null) return 0;
        int changeCount = gasUserEntityMapper.updateByPrimaryKey(record);
        return changeCount;
    }

    public int updateProps(GasUserCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = gasUserEntityCustomMapper.updateProps(queryModel);
        return changeCount;
    }

    public GasUserEntity selectEntity(GasUserCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<GasUserEntityExt> extList = gasUserEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<GasUserEntity> selectEntityList(GasUserCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<GasUserEntityExt> extList = gasUserEntityCustomMapper.selectExt(queryModel);
        if (extList == null) return null;
        List<GasUserEntity> entityList = new ArrayList<>();
        for (GasUserEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public GasUserEntityExt selectExt(GasUserCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<GasUserEntityExt> extList = gasUserEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<GasUserEntityExt> selectExtList(GasUserCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<GasUserEntityExt> extList = gasUserEntityCustomMapper.selectExt(queryModel);
        return extList;
    }

    public GasUserEntity selectBasicInfoEntity(GasUserCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<GasUserEntityExt> extList = gasUserEntityCustomMapper.selectBasicInfoExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<GasUserEntity> selectBasicInfoEntityList(GasUserCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<GasUserEntityExt> extList = gasUserEntityCustomMapper.selectBasicInfoExt(queryModel);
        if (extList == null) return null;
        List<GasUserEntity> entityList = new ArrayList<>();
        for (GasUserEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public GasUserEntityExt selectBasicInfoExt(GasUserCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<GasUserEntityExt> extList = gasUserEntityCustomMapper.selectBasicInfoExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<GasUserEntityExt> selectBasicInfoExtList(GasUserCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<GasUserEntityExt> extList = gasUserEntityCustomMapper.selectBasicInfoExt(queryModel);
        return extList;
    }

    public int selectCount(GasUserCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int count = gasUserEntityCustomMapper.selectCount(queryModel);
        return count;
    }
}
